<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script>
			{
				//set的使用
				const s = new Set();
				let arr = [1, 2, 3, 4, 5, 6, 7, 2, 3];
				arr.forEach(item => s.add(item));
				console.log(s);
			} {
				//数组去重方式1
				let arr = [1, 2, 3, 4, 5, 6, 7, 2, 3];
				let arrSet = [...new Set(arr)];
				console.log(arrSet);
			}
			
			{
				//数组去重方式2
				const items = new Set([1, 2, 3, 4, 5, 6, 7, 2, 3]);
				const array = Array.from(items);
				console.log(array);
			}
			{
				//封装成方法
				function dedupe(array) {
				  return Array.from(new Set(array));
				}
				
				dedupe([1, 1, 2, 3]) // [1, 2, 3]
			}
		</script>
	</body>

</html>